package com.semidata.trp.business.http;

import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.HttpRequest;

import com.semidata.rtd.core.http.server.DefaultDispatcher;
import com.semidata.rtd.core.http.server.HttpDispatchHandler;
import com.semidata.rtd.core.http.server.UrlMatcher;
import com.semidata.trp.business.config.Config;

public class BusinessHttpDispatcher extends DefaultDispatcher {

    public BusinessHttpDispatcher() {

        Config config = Config.getConfig();
        
        addUrlMatcher(new UrlMatcher(config.getReportProviderUrl()) {
            @Override
            protected HttpDispatchHandler createHandler(ChannelHandlerContext ctx, HttpRequest request) {
                return new ReportProviderHttpHandler(ctx, request);
            }
        });

        addUrlMatcher(new UrlMatcher(config.getRegisterUrl()) {

            @Override
            protected HttpDispatchHandler createHandler(ChannelHandlerContext ctx, HttpRequest request) {
                return new RegisterHttpHandler(ctx, request);
            }

        });

        addUrlMatcher(new UrlMatcher(config.getReportMonitorUrl()) {

            @Override
            protected HttpDispatchHandler createHandler(ChannelHandlerContext ctx, HttpRequest request) {
                return new MonitorReportHttpHandler(ctx, request);
            }
        });

    }

}
